//返回首页
	function backUp(){
		appControl.toHome();
	}

//显示消费查询页面
function show_log(){
	appControl.toSrchPage();
}

var pwdDiv_index;
var updatePwd_index;

var goType = "";
//显示消费纠错页面
function show_jc(){
	goType = "1";
	//先验证用户密码
	
	pwdDiv_index = layer.open({
		  type: 1,
		  skin: 'layui-layer-rim', //加上边框
		  area: ['800px', '400px'], //宽高
		  content:$("#pwdDiv"),
		  title:"操作密码",
		   offset: '10px'
		});
		
		$("#operPwd").focus();
		
	
}


function toOperPwd(){
	updatePwd_index= layer.open({
		  type: 1,
		  skin: 'layui-layer-rim', //加上边框
		  area: ['620px', '460px'], //宽高
		  content:$("#operpwd")
		});
}




function updateOperPwd(){
	
	
	
		var old_pwd = $.trim($("#old_pwd").val());
		var new_pwd = $.trim($("#new_pwd").val());
		var confirm_pwd = $.trim($("#confirm_pwd").val());
		
		if(old_pwd=="" || new_pwd=="" || confirm_pwd==""){
			layer.msg("密码不能为空");
			return;
		}
		
		if(new_pwd!=confirm_pwd){
			layer.msg("新密码和确认信密码不一致");
			return;
		}
	
	
		//提交通讯参数
		var rs = appControl.doUpdatePwd($("#old_pwd").val(),$("#new_pwd").val());
		
		if(rs=="1"){
			layer.msg("修改密码成功");
		}else if(rs=="-1"){
			layer.msg("系统异常");
		}else{
			//后台错误信息
			layer.msg(rs);
		}
	
}

function closeOperPwd(){
	layer.close(updatePwd_index);
}

function submitUserPwd(){
	
	var pwd = $.trim($("#operPwd").val());
	if(pwd==""){
		layer.msg("请输入操作密码");
		return;
	}
	var rs = appControl.validateOperPwd(pwd);
	if(rs=="1"){
		
		if(goType=="1"){
			appControl.toJcPage();
		}else if(goType=="2"){
			appControl.toConsumeBackPage();
		}
		
		goType = "";
	}else if(rs=="0"){
		$("#operPwd").val("")
		layer.msg("密码错误");
	}else{
		$("#operPwd").val("")
		layer.msg("系统错误");
	}
}

function cancelSubmitUserPwd(){
	layer.close(pwdDiv_index);
}


function toPrint(){
	appControl.toPrint();
}


//显示消费回退页面
function show_back(){
	
}
//显示消费统计页面
function show_stat(){
	
	appControl.toConsumePrintPage();
}

function show_jclog(){
	
	appControl.toJcLogPage();
}



function toConsumeBack(){
	
	
	goType = "2";
	//先验证用户密码
	
	pwdDiv_index = layer.open({
		  type: 1,
		  skin: 'layui-layer-rim', //加上边框
		  area: ['800px', '400px'], //宽高
		  content:$("#pwdDiv"),
		  title:"操作密码",
		   offset: '10px'
		});
		
		$("#operPwd").focus();
	
	//appControl.toConsumeBackPage();
}

var quotaConsumeDiv;
/**
 * 定额消费设置页面
 */
function toQuotaConsume(){
	
	
	var rs = appControl.queryConsumeQuato();
	
	quotaConsumeDiv = layer.open({
		  type: 1,
		  skin: 'layui-layer-rim', //加上边框
		  area: ['800px', '400px'], //宽高
		  content:$("#quotaConsume"),
		  title:"消费定额设置",
		   offset: '10px'
		});
	if(rs!="-1"){
		var arr = rs.split(",");
		$("#quotaConsumeSel").val(arr[0]);
		$("#quotaMoney").val("");
		if(arr[0]=="0"){
			//非定额消费
			$("#quotaMoneyTr").hide();
		}else{
			$("#quotaMoneyTr").show();
			$("#quotaMoney").val(arr[1]);
			
		}
	}
}



function closeQuotaConsume(){
	layer.close(quotaConsumeDiv);
}


function updateQuotaConsume(){
	
	//保存定额消费设置
	var selQuato = $("#quotaConsumeSel").val();
	var quatoMoney = "0";
	if(selQuato=="1"){
		//非
		quatoMoney = $("#quotaMoney").val();
		if(quatoMoney=="" ||  quatoMoney=="0"){
			layer.msg("请输入定额消费金额");
			return;
		}
	}
	//保留数据
	var rs  = appControl.saveQuatoInfo(selQuato,quatoMoney);
	if(rs=="1"){
		layer.msg("设置成功");
	}else{
		layer.msg("设置失败");
	}
	
}

function changeQuato(obj){
	if(obj=="0"){
		$("#quotaMoneyTr").hide();
	}else{
		$("#quotaMoneyTr").show();
		
	}
}
